package com.hky.algorithm.realize;

import org.junit.Test;

import java.util.Scanner;

public class MyTest {


    public static void main(String[] args) {
        Game game = Game.buildGame4();

        Calculator.calculate(game);

        for (Term term : game.terms) {
            term.printlnAllCards();
        }
    }

    @Test
    public void r1() {
        Scanner sc = new Scanner(System.in);
        int[] tong = new int[10];
        int[] tiao = new int[10];
        int[] wan = new int[10];

        while (true) {
            System.out.println("输入：（w t y，万 筒 条）");
            String s = sc.nextLine();
            if (s.equalsIgnoreCase("show")) {
                System.out.print("new Term(new int[]{0");
                for (int i = 1; i < tong.length; i++) {
                    System.out.print(", " + tong[i]);
                }
                System.out.println("}, Type.TONG),");

                System.out.print("new Term(new int[]{0");
                for (int i = 1; i < wan.length; i++) {
                    System.out.print(", " + wan[i]);
                }
                System.out.println("}, Type.WAN),");

                System.out.print("new Term(new int[]{0");
                for (int i = 1; i < tiao.length; i++) {
                    System.out.print(", " + tiao[i]);
                }
                System.out.println("}, Type.TIAO)");

                continue;
            } else if (s.equalsIgnoreCase("end"))  break;

            String[] strs = s.split(" ");
            System.out.println("共 " + (strs.length - 2) + " 张牌");

            int[] term = tong;
            if (strs[0].charAt(0) == 'w') term = wan;
            else if (strs[0].charAt(0) == 'y') term = tiao;

            for (int i = 1; i < strs.length - 1; i++) {
                term[strs[i].charAt(0) - '0'] += Integer.parseInt(strs[strs.length - 1]);
            }
        }
    }
}
